<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>书籍列表</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../static/css/animate.css" th:href="@{/css/animate.css}">
    <link rel="stylesheet" href="../static/css/me.css" th:href="@{/css/me.css}">
</head>
<body>

<style>

    p {
        text-align: center;
    }

    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
    }

    header {
        background-color: #f8f9fa;
        padding: 20px;
        text-align: center;
    }

    .product-container {
        display: flex;
        justify-content: space-between;
        padding: 20px;
    }

    .product-column {
        flex: 1;
        margin-right: 20px;
    }

    .product-column:last-child {
        margin-right: 0;
    }

    .product-item {
        margin-bottom: 20px;
        border: 1px solid #7777cc;
        border-radius: 20px;
        padding: 10px;
        text-align: center;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

    }

    .product-item img {
        width: 100%;
        height: auto;
        display: block;
        margin-bottom: 10px;
    }

    .product-item h3 {
        font-size: 16px;
        margin: 0;
    }

    .product-item p {
        font-size: 14px;
        margin: 5px 0;
    }

    footer {
        background-color: #f8f9fa;
        padding: 20px;
        text-align: center;
        position: fixed;
        bottom: 0;
        width: 100%;
    }
    .book-container {
        width: 320px; /* 设置书籍容器的宽度 */
        height: auto; /* 或者您可以设置固定的高度，如果您希望所有书籍容器具有相同的高度 */
        margin: 10px; /* 可选：设置书籍容器之间的间距 */
    }

    .book-container img {
        width: 100%; /* 图像宽度占满书籍容器 */
        height: 350px; /* 图像高度自适应 */
    }
    #comment-container{
        width: 760px;
        height: 350px;
        overflow: auto;
        margin-bottom: 42px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .book-info {
        background-color:transparent; /* 设置背景颜色 */
        padding: 10px; /* 设置内边距 */
        border-radius: 20px; /* 设置圆角 */
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 设置阴影 */
        width: 300px; /* 设置宽度 */
    }

    /* 图片样式 */
    .book-info img {
        width: 100%; /* 图片宽度100% */
        height: auto; /* 高度自适应 */
        border-radius: 5px; /* 圆角 */
        margin-bottom: 10px; /* 底部间距 */
    }

    /* 书名样式 */
    .book-info h3 {
        font-size: 18px; /* 设置字体大小 */
        margin: 0; /* 去除默认外边距 */
        color: #333; /* 设置文字颜色 */
        text-align: center;
    }

    /* 分数样式 */
    .book-info .score {
        font-size: 18px; /* 设置字体大小 */
        color: #FF5733; /* 设置文字颜色 */
        text-align: center;
    }

</style>
<style>
    .vip{
        background-image: url("../image/vip.png");
        width: 20px;
        height: 20px;
        display: inline-block;
        vertical-align: middle;
        background-size: 100%;
    }
</style>
    <!--导航-->
    <!--inverted:反色、attached:没有圆角，依附在上面:m-padded-tb-mini:m自己定义,padded,上下之间内部间隔,tb上下,mini小点-->
    <!--m-shadow-small:自定义导航阴影-->
    <!--导航-->
    <nav class="ui m-bg attached segment m-padded-tb-mini m-shadow-small" >
        <div class="ui container">
            <div class="ui secondary stackable menu">
                <h2 class="ui purple header item">书籍列表</h2>
                <a href="#" th:href="@{/index}" class="m-item item m-mobile-hide m-black"><i class=" user secret icon"></i>首页</a>
                <a href="#" th:href="@{/books}" class="m-item item m-mobile-hide m-black"><i class="user secret icon"></i>图书信息</a>
                <a href="#" th:href="@{/goodBooks}" class="active m-item item m-mobile-hide m-black"><i class="user secret icon"></i>推荐好书</a>
                <a href="#" th:href="@{/borrow}" class="m-item item m-mobile-hide m-black"><i class="users secret icon"></i>我的借阅</a>
               <a href="#" th:href="@{/alter}" class="m-item item m-mobile-hide m-black"><i class="users secret icon"></i>个人中心</a>
                <div class="right m-item m-mobile-hide menu">
                    <div class="ui dropdown  item">
                        <div class="text">
                            <i class="user plus icon " style="width: 20px;height: 20px"></i>
                            <i th:if="${userMessage.getVip()!=0}" class="vip" style="width: 20px;height: 20px"></i>
                            <label th:text="${userMessage.getStuname()}"></label>
                        </div>
                        <i class="dropdown icon"></i>
                        <div class="menu">
                            <a href="#" th:href="@{/alter}" class="item">修改信息</a>
                            <a href="#" th:href="@{/logouts}" class="item">注销</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show">
            <i class="sidebar icon"></i>
        </a>
    </nav>

    <!--中间内容-->
    <div  class="m-container-small m-padded-tb-big animated zoomIn">
        <div class="ui container">
            <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
                <i class="close icon"></i>
                <div class="header">提示：</div>
                <p th:text="${message}">恭喜，借阅成功！</p>
            </div>

            <div  class="ui secondary segment form">
                <input type="hidden" name="pageNum" >
                <div class="inline fields">
                    <div class="field">
                        <input type="text" id="bookId" name="bookId" placeholder="书号">
                    </div>
                    <div class="field">
                        <input type="text" id="name" name="name" placeholder="书名">
                    </div>
                    <div class="field">
                        <button  type="submit" id="search-btn" class="ui purple basic button"><i class="search icon"></i>搜索</button>
                    </div>
                </div>
            </div>
            <div id="table-container">
                <div class="product-container" th:fragment="pageList">
                        <div class="product-item"  >
                           <table  class="ui celled table" style="background-color: transparent">
                            <tr th:each="book : ${pageInfo.list}">
                                        <td>
                                            <div class="book-info">
                                            <a th:href="@{/bookXQ?(bookId=${book.getBookId()})}">
                                                <img th:src="${book.img}" />

                                            </a>
                                            <h3 th:text="${book.name}"></h3>
                                            <div class="score"> <i class="star icon"></i>分数：<span th:text="${book.good}"></span></div>
                                          </div>
                                        </td>
                                         <td>
                                             <div id="comment-container" class="ui teal segment">
                                                 <div>
                                                     <div class="ui threaded comments" style="max-width: 100%;">
                                                         <h3 class="ui dividing header">评论</h3>
                                                         <div class="comment" th:each="comment : ${book.getComments()}">
                                                             <a class="avatar">
                                                                 <img src="../static/image/user.png" th:src="@{/image/user.png}">
                                                             </a>
                                                             <div class="content">
                                                                 <a class="author">
                                                                     <span th:text="${comment.nickname}">Matt</span>
                                                                     <!--                                        <div class="ui mini basic red left pointing label m-padded-mini" th:if="${comment.adminComment}">管理员</div>-->
                                                                 </a>
                                                                 <div class="metadata">
                                                                     <span class="date" th:text="${#dates.format(comment.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                                                     <span class="date" th:text="'评分:'+ ${comment.score}"></span>
                                                                 </div>
                                                                 <div class="text" th:text="${comment.content}">
                                                                     How artistic!
                                                                 </div>
                                                                 <div class="actions">
                                                                     <!--                                        <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${comment.id},data-commentnickname=${comment.nickname}" onclick="reply(this)">回复</a>-->
                                                                     <a class="delete" href="#" th:if="${userMessage.getRole()=='admin'}" th:href="@{/comment/{param}/{param2}/delete(param=${comment.id},param2=${comment.bookId})}" onclick="return confirm('确定要删除该评论吗？三思啊! 删了可就没了！')">删除</a>
                                                                 </div>
                                                             </div>
                                                             <!--这里是嵌套的-->
                                                             <div class="comments" th:if="${#arrays.length(comment.replyComments)}>0">   <!--判断大于0，才显示这块区域-->
                                                                 <div class="comment" th:each="reply : ${comment.replyComments}">    <!--评论子类-->
                                                                     <a class="avatar">
                                                                         <img src="../static/image/user.png" th:src="@{/image/user.png}">
                                                                     </a>
                                                                     <div class="content">
                                                                         <a class="author" >
                                                                             <span th:text="${reply.nickname}">小红</span>
                                                                             <!--                                                <div class="ui mini basic red left pointing label m-padded-mini" th:if="${reply.adminComment}">管理员</div>-->
                                                                             &nbsp;<span th:text="|@ ${reply.parentNickname}|" class="m-teal">@ 小白</span>
                                                                             <!--显示出某某某@某某某-->
                                                                         </a>
                                                                         <div class="metadata">
                                                                             <span class="date" th:text="${#dates.format(reply.createTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                                                                         </div>
                                                                         <div class="text" th:text="${reply.content}">
                                                                             This has been very useful for my research. Thanks as well!
                                                                         </div>
                                                                         <div class="actions">
                                                                             <!--                                                <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${reply.id},data-commentnickname=${reply.nickname}" onclick="reply(this)">回复</a>-->
                                                                             <a class="delete" href="#" th:if="${userMessage.getRole()=='admin'}" th:href="@{/comment/{param}/{param2}/delete(param=${comment.id},param2=${comment.bookId})}" onclick="return confirm('确定要删除该评论吗？三思啊! 删了可就没了！')">删除</a>
                                                                         </div>
                                                                     </div>
                                                                 </div>
                                                             </div>
                                                         </div>

                                                     </div>
                                                 </div>
                                             </div>
                                         </td>
                                     </tr>
                             </table>


                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>
    <br>
    <br>
    <!--底部footer-->
    <footer th:fragment="footer" class="ui m-bg animated fadeInUp inverted vertical segment m-padded-tb-massive">
        <div class="ui center aligned container">
            <div class="ui inverted divided stackable grid">
                <div class="three wide column">
                    <div class="ui inverted link list">
                    </div>
                </div>
                <div class="three wide column">
                    <div id="newblog-container">
                    </div>
                </div>
                <div class="three wide column">

                </div>
            </div>
            <div class="ui inverted m-black section divider"></div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
    <script src="../static/js/colourBar.js" th:src="@{/js/colourBar.js}" tppabs="../static/js/colourBar.js"></script>

    <script th:inline="javascript">
        var message = [[${message}]];
        if(message != null){
            alert(message)
        }

        $('.menu.toggle').click(function () {
            $('.m-item').toggleClass('m-mobile-hide');
        });

        $('.ui.dropdown').dropdown({
            on : 'hover'
        });

        //消息提示关闭初始化
        $('.message .close')
            .on('click', function () {
                $(this)
                    .closest('.message')
                    .transition('fade');
            });

        function page(obj) {
            $("[name='pageNum']").val($(obj).data("page"));//获取page隐含域赋值
            loaddata();
        }

        // 点击事件；page清零，搜索不会查询某一页
        $("#search-btn").click(function () {
            // $("[name='pageNum']").val(0);
            loaddata();
        });

        $("#searchE-btn").click(function () {
           location.href = "http://localhost:8080/newGoodBooks" ;
        });

        // 点击事件；page清零，搜索不会查询某一页
        $("#more").click(function () {
            // $("[name='pageNum']").val(0);
            loaddata();
        });

        //用来请求发送数据
        function loaddata() {
            $("#table-container").load("/goodBooks/search",{
                bookId : $("[name='bookId']").val(),
                name : $("[name='name']").val(),
                pageNum : $("[name='pageNum']").val()
            });
        }

    </script>
    <script src="../static/js/colourBar.js" th:src="@{/js/colourBar.js}" tppabs="../static/js/colourBar.js"></script>


</body>
</html>